<template>
	<view class="content">
		<div class="my_work_box" id="myworkbox">
			<div class="titlebox">
				<text style="color: black;font-size: 21px;font-weight:bold">审核</text>
			</div>
			<scroll-view scroll-y="true"  show-scrollbar="false" class="public_box">
				<div v-for="item in processList" class="process_box">
					<p style="font-weight: bold;font-size: 16px;margin: 10px 10px;">{{item.title}}</p>
					<p style="font-size: 14px;margin: 10px 10px;">时间：{{ item.starttime }}至{{ item.endtime }}</p>
					<p style="font-size: 14px;margin: 10px 10px;">参与方式：{{ item.space }}</p>
					<p style="font-size: 14px;margin: 10px 10px;">范围：{{ item.range }}</p>
					<p style="font-size: 14px;margin: 10px 10px;">类型：{{ item.type }}</p>
					<p style="font-size: 14px;margin: 10px 10px;">提交时间：{{ item.CreateTime }}</p>
					<div class="process_bar">
						<div style="flex: 1;background: green;width: 100%;display:flex;height: 40px;align-items: center;justify-content: center;" @click="process('pass',item.eventid)">
							<text style="color: white;">通过</text>
						</div>
						<div style="flex: 1;background: red;width: 100%;display:flex;height: 40px;align-items: center;justify-content: center;" @click="process('delete',item.eventid)">
							<text style="color: white;">删除</text>
						</div>
					</div>
				</div>
			</scroll-view>
		</div>
	</view>
</template>

<script>
	export default {
		onShareAppMessage(){},
		onShareTimeline(){},
		data() {
			return {
				process_evenList: [],
				processList: [],
			}
		},
		created() {
			this.onloadLayout()
			this.remove_old()
		},
		methods: {
			onloadLayout() {
				uni.request({
					url: 'https://127.0.0.1/data/getevent.php',
					method: 'POST',
					header: {
						'content-type': 'application/json',
					},
					success: (res) => {
						this.process_evenList = res.data;
						this.processList = this.process_evenList.filter(item => item.status == 0);
					}
				})
			},
			remove_old(){
				uni.request({
					url: 'https://127.0.0.1/data/remove_old.php',
					method: 'GET',
					header: {
						'content-type': 'application/json',
					},
					success: (res) => {
						console.log(res)
					}
				})
			},
			process(decisions, eventid) {
				let processinfo={
					"eventid":eventid,
					"decision":decisions
					}
				uni.request({
					url: 'https://127.0.0.1/data/process.php',
					method: 'POST',
					header: {
						'content-type': 'application/json',
					},
					data:processinfo,
					success: (res) => {
						if(res.data==='操作成功'){
							console.log("pass")
							this.onloadLayout()
						}
						else{
							console.log(res)
						}
					}
				})
			},
		}
	}
</script>

<style>
	template{
		background-color: #f8f8f8;
	}
	.process_box {
		width: 95%;
		height: 100%;
		margin: 10px 15px;
		border-radius: 14px;
		background: white;
		overflow: hidden;
		backface-visibility: hidden;
	}

	.content {
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: column;
		align-items: left;
		justify-content: center;
		background: white;
		background-color: #f8f8f8;
	}

	.titlebox {
		top: 0;
		display: flex;
		flex-direction: row;
		align-items: center;
		margin-left: 21px;
		margin-bottom: 30px;
		letter-spacing: 1px;
	}

	.my_work_box {
		margin: 14.2% 0 0 0;
		display: flex;
		flex-direction: column;
		align-items: left;
		justify-content: center;
	}

	.public_box {
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
	}
	.process_bar{
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		flex: 1;
		margin-top: 10px;
		align-items: center;
	}
</style>